
#include "stdafx.h"
#include "WicFormatConverterInfo.h"
#include "WicFormatConverter.h"
#include "WicComponentInfo.h"

//==============================================================================
// IWICComponentInfo
//==============================================================================
CWicFormatConverterInfo::CWicFormatConverterInfo(CWicComponentInfo *pComponentInfo)
{
    m_pIWICFormatConverterInfo = NULL;
    g_hrLast = pComponentInfo->m_pIWICComponentInfo->QueryInterface(
        IID_IWICFormatConverterInfo, (void**)&m_pIWICFormatConverterInfo);
}

CWicFormatConverterInfo::~CWicFormatConverterInfo()
{
    if(m_pIWICFormatConverterInfo)
    {
        m_pIWICFormatConverterInfo->Release();
    }
    m_pIWICFormatConverterInfo = NULL;
}

CWicFormatConverterInfo::CWicFormatConverterInfo(CWicFormatConverterInfo const & objFormatConverterInfo)
{
    m_pIWICFormatConverterInfo = objFormatConverterInfo.m_pIWICFormatConverterInfo;
    m_pIWICFormatConverterInfo->AddRef();
}

CWicFormatConverterInfo& CWicFormatConverterInfo::operator=(CWicFormatConverterInfo const & objFormatConverterInfo)
{
    if(m_pIWICFormatConverterInfo)
    {
        m_pIWICFormatConverterInfo->Release();
    }
    m_pIWICFormatConverterInfo = objFormatConverterInfo.m_pIWICFormatConverterInfo;
    m_pIWICFormatConverterInfo->AddRef();
    return *this;
}

//==============================================================================
// IWICComponentInfo
//==============================================================================

HRESULT CWicFormatConverterInfo::GetPixelFormats(
                        /* [in] */ UINT cFormats,
                        /* [size_is][out][in] */ WICPixelFormatGUID *pPixelFormatGUIDs,
                        /* [out] */ UINT *pcActual)
{
    g_hrLast = m_pIWICFormatConverterInfo->GetPixelFormats(cFormats, pPixelFormatGUIDs, pcActual);
    return g_hrLast;
}

CWicFormatConverter* CWicFormatConverterInfo::CreateFormatConverter()
{
    CWicFormatConverter *ptr = new CWicFormatConverter(*this);
    return ptr;
}

//==============================================================================
// IWICComponentInfo
//==============================================================================
WICComponentType CWicFormatConverterInfo::GetComponentType()
{
    WICComponentType type;
    g_hrLast = m_pIWICFormatConverterInfo->GetComponentType(&type);
    return type;
}

HRESULT CWicFormatConverterInfo::GetCLSID(/* [out] */ CLSID *pclsid)
{
    g_hrLast = m_pIWICFormatConverterInfo->GetCLSID(pclsid);
    return g_hrLast;
}

DWORD CWicFormatConverterInfo::GetSigningStatus()
{
    DWORD dwStatus = 0;
    g_hrLast = m_pIWICFormatConverterInfo->GetSigningStatus(&dwStatus);
    return dwStatus;
}

UINT CWicFormatConverterInfo::GetAuthor(UINT cchAuthor, WCHAR *wzAuthor)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICFormatConverterInfo->GetAuthor(cchAuthor, wzAuthor, &uResult);
    return uResult;
}

HRESULT CWicFormatConverterInfo::GetVendorGUID(/* [out] */ GUID *pguidVendor)
{
    g_hrLast = m_pIWICFormatConverterInfo->GetVendorGUID(pguidVendor);
    return g_hrLast;
}

UINT CWicFormatConverterInfo::GetVersion(UINT cchVersion, WCHAR *wzVersion)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICFormatConverterInfo->GetVersion(cchVersion, wzVersion, &uResult);
    return uResult;
}

UINT CWicFormatConverterInfo::GetSpecVersion(UINT cchSpecVersion, WCHAR *wzSpecVersion)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICFormatConverterInfo->GetSpecVersion(cchSpecVersion, wzSpecVersion, &uResult);
    return uResult;
}

UINT CWicFormatConverterInfo::GetFriendlyName(UINT cchFriendlyName, WCHAR *wzFriendlyName)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICFormatConverterInfo->GetFriendlyName(cchFriendlyName, wzFriendlyName, &uResult);
    return uResult;
}
